/*
 * @Author: your name
 * @Date: 2021-02-22 15:08:05
 * @LastEditTime: 2021-02-22 15:15:14
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \auth\src\common\errorHandle.ts
 */
export default (ctx: any, next: any) => {
    return next().catch((err: any) => {
        if (401 == err.status) {
            ctx.status = 401;
            ctx.body = {
                code: 1,
                msg: 'Protected resource, use Authorization header to get access\n',
                success: false
            }
        } else {
            throw err;
        }
    });
}